home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 February / enter-2006-02.iso / files / Illustrator_CS2_ue_TryOut.exe / bridge / Adobe Bridge 1.0.msi / Data1.cab / _4window.jsx < prev    next >
Encoding:
Text File  |  2005-03-24  |  6.3 KB  |  212 lines

  1. /**************************************************************************
  2. *
  3. *  @@@BUILDINFO@@@ 04window.jsx 1.0.0.48 07-Feb-2005
  4. *  Copyright 2005 Adobe Systems Incorporated
  5. *  All Rights Reserved.
  6. *
  7. * NOTICE:  All information contained herein is, and remains the property of
  8. * Adobe Systems Incorporated  and its suppliers,  if any.  The intellectual 
  9. * and technical concepts contained herein are proprietary to  Adobe Systems 
  10. * Incorporated  and its suppliers  and may be  covered by U.S.  and Foreign 
  11. * Patents,patents in process,and are protected by trade secret or copyright 
  12. * law.  Dissemination of this  information or reproduction of this material
  13. * is strictly  forbidden  unless prior written permission is  obtained from 
  14. * Adobe Systems Incorporated.
  15. **************************************************************************/
  16.  
  17. // Additions to the Window object.
  18.  
  19. // Iterate through all of the BridgeTalk interface definitions attached to
  20. // the BridgeTalk object and load the apps listbox with all display names.
  21. // Attach the BridgeTalk name to every list item.
  22.  
  23. Window.prototype.loadApps = function()
  24. {
  25.     // add myself
  26.     this.addApplication (BridgeTalk.appSpecifier, window.title);
  27.  
  28.     var i;
  29.     // First, get the BT specifiers for the most recent installed apps
  30.     var latestApps = BridgeTalk.getTargets (null, null);
  31.     // set the BT specifiers as properties for easier lookup
  32.     for (var i = 0; i < latestApps.length; i++)
  33.         latestApps [latestApps [i]] = true;
  34.     // we want to offer all possible targets
  35.     var apps = BridgeTalk.getTargets (-999, null);
  36.     var curLocale = $.locale.toLowerCase();
  37.  
  38.     // determine for each app if version and/or locale info needs to be added
  39.     // collect this stuff into the following object, create subobjects holding
  40.     // booleans for versions and locales needed
  41.     var testObj = {};
  42.     for (var pass = 1; pass <= 2; pass++)
  43.     {
  44.         for (var i = 0; i < apps.length; i++)
  45.         {
  46.             // the target is now fully qualified
  47.             var app = apps [i];
  48.             var target  = app.split ('-');
  49.             var version = target [1];
  50.             var locale  = target [2];
  51.             target      = target [0];
  52.             // Ignore the Help Center for now
  53.             if (target == "helpcenter")
  54.                 continue;
  55.             // do not load info about myself
  56.             if (target != BridgeTalk.appName)
  57.             {
  58.                 var appObj = testObj [target];
  59.                 if (!appObj)
  60.                     appObj = testObj [target] = 
  61.                 { needVersion:false, needLocale:false, version:version, locale:locale };
  62.                 if (pass == 1)
  63.                 {
  64.                     // pass 1: collect information
  65.                     if (appObj.version != version)
  66.                         appObj.needVersion = true;
  67.                     if (appObj.locale != locale)
  68.                         appObj.needLocale = true;
  69.                 }
  70.                 else
  71.                 {
  72.                     // pass 2: generate the entries
  73.                     var displayName = BridgeTalk.getDisplayName (app);
  74.                     // OK, the dislay name is valid - we can use it
  75.                     if (displayName)
  76.                     {
  77.                         // need to add version and/or locale?
  78.                         if (appObj.needVersion && appObj.needLocale)
  79.                             displayName += " (" + version + ", " + locale + ")";
  80.                         else if (appObj.needVersion)
  81.                             displayName += " (" + version + ")";
  82.                         else if (appObj.needLocale)
  83.                             displayName += " (" + locale + ")";
  84.                         this.addApplication (app, displayName);
  85.                     }
  86.                 }
  87.             }
  88.         }
  89.     }
  90. }
  91.  
  92. // Add an app to the Apps drop-down box.
  93.  
  94. Window.prototype.addApplication = function (target, name)
  95. {
  96.     // overcome an installer bug
  97.     if (name.length > 4)
  98.     {
  99.         var index = name.lastIndexOf (".app");
  100.         if (index == name.length - 4)
  101.             name = name.substr (0, index);
  102.     }
  103.     // Capitalize the first character (for apps that connect directly)
  104.     if (name [0] >= 'a' && name [0] <= 'z')
  105.         name = name.toUpperCase()[0] + name.substr (1);
  106.     BridgeTalk.addTarget (target, name);
  107.     this.apps.add ("item", name);
  108. }
  109.  
  110. // Add an engine.
  111.  
  112. Window.prototype.addEngine = function (engine)
  113. {
  114.     var item = this.engines.add ("item", engine);
  115.     this.engines.all [engine] = item;
  116. }
  117.  
  118. // Add the engines to the Engines drop-down list
  119.  
  120. Window.prototype.setupEngines = function (target)
  121. {
  122.     this.engines.removeAll();
  123.     this.engines.all = {};
  124.  
  125.     var debuggers = Debugger.getAll (target);
  126.     for (var i = 0; i < debuggers.length; i++)
  127.     {
  128.         var dbg = debuggers [i];
  129.         this.addEngine (dbg.engine);
  130.         this.setEngineState (dbg);
  131.     }
  132. }
  133.  
  134. // Reflect the state of the given debugger into the Engines drop-down.
  135. // If there is no debugger supplied, use the current debugger.
  136.  
  137. Window.prototype.setEngineState = function (dbg)
  138. {
  139.     if (!dbg)
  140.         dbg = currentDebugger;
  141.     if (dbg)
  142.     {
  143.         var engine = dbg.engine;
  144.         var item = this.engines.all [engine];
  145.         if (item)
  146.         {
  147.             switch (dbg.state)
  148.             {
  149.                 case Debugger.RUNNING:    item.icon = "RunningEngine"; break;
  150.                 case Debugger.STOPPED:    item.icon = "StoppedEngine"; break;
  151.                 case Debugger.WAITING:    item.icon = "WaitingEngine"; break;
  152.                 default:                item.icon = "InactiveEngine";
  153.             }
  154.         }
  155.     }
  156. }
  157.  
  158. // Select an application/engine combination.
  159. // the app name is the BridgeTalk name. If the engine name is omitted,
  160. // clear all engines.
  161.  
  162. Window.prototype.selectAppAndEngine = function (target, engine)
  163. {
  164.     var displayName = BridgeTalk.getTargetDisplayName (target);
  165.     if (displayName)
  166.         this.apps.selection = this.apps.find (displayName);
  167.     if (engine)
  168.     {
  169.         item = this.engines.all [engine];
  170.         if (item)
  171.             this.engines.selection = item;
  172.     }
  173.     else
  174.         this.engines.removeAll();
  175. }
  176.  
  177. // Selection callback for the Applications combobox.
  178. // This routine always connects to the target and
  179. // sees if it is up and running. The Debugger.connect()
  180. // method fills in the list of engines and sets up the 
  181. // Engines combobox.
  182.  
  183. window.apps.onChange = function()
  184. {
  185.     if (this.selection)
  186.     {
  187.         // find the target name for the selection
  188.         var target = BridgeTalk.getTargetByDisplayName (this.selection.text);
  189.         if (target && BridgeTalk.launchTarget (target))
  190.             Debugger.connect (target);
  191.     }
  192. }
  193.  
  194. // Define the callback for the engine selection combobox in the toolbar
  195.  
  196. window.engines.onChange = function()
  197. {
  198.     if (this.selection)
  199.     {
  200.         var target = BridgeTalk.getTargetByDisplayName (window.apps.selection.text);
  201.         var engine = this.selection.text;
  202.         var dbg = null;
  203.         if (engine && target)
  204.             dbg = Debugger.find (target, engine);
  205.         if (dbg)
  206.             // there is a debugger active for this engine. Bring that doc to the front!
  207.             dbg.activate();
  208.         else
  209.             currentDebugger.activate();
  210.     }
  211. }
  212.